Routines (alphabetical) > Routines: S > SYSTIME

SYSTIME

Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The SYSTIME function returns the current time as either a date/time string, as the number of seconds elapsed since 1 January 1970, or as a Julian date/time value.

Syntax

String = SYSTIME( [0 [, ElapsedSeconds]] [, /UTC] )

or

Seconds = SYSTIME( 1 | /SECONDS )

or

Julian = SYSTIME( /JULIAN [, /UTC] )

Return Value

Returns the specified time.

Arguments

SecondsFlag

If SecondsFlag is present and nonzero, the number of seconds elapsed since 1 January 1970 UTC is returned as a double-precision, floating-point value.

Note: The precision of the returned value depends on your platform:
  On Windows platforms, the value is expressed as seconds.milliseconds.
  On UNIX platforms, the value is expressed as seconds.microseconds.

Otherwise, if SecondsFlag is not present or zero, a scalar string containing the date/time is returned in standard 24-character system format as follows:

DOW MON DD HH:MM:SS YEAR

where DOW is the day of the week, MON is the month, DD is the day of the month, HH is the hour, MM is the minute, SS is the second, and YEAR is the year. By default, the date/time string is adjusted for the local time zone; use the UTC keyword to override this default.

Note: If the JULIAN or SECONDS keyword is set, the SecondsFlag argument is ignored.

ElapsedSeconds

If the SecondsFlag argument is zero, the ElapsedSeconds argument may be set to the number of seconds past 1 January 1970 UTC. In this case, SYSTIME returns the corresponding date/time string (rather than the string for the current time). The returned date/time string is adjusted for the local time zone, unless the UTC keyword is set. If this argument is present, the JULIAN keyword is not allowed.

Keywords

JULIAN

Set this keyword to specify that the current time is to be returned as a a double precision floating value containing the current Julian date/time. By default, the current time is adjusted for the local time zone; use the UTC keyword to override this default. This keyword is not allowed if the ElapsedSeconds argument is present.

Note: If the JULIAN keyword is set, a small offset is added to the returned Julian date to eliminate roundoff errors when calculating the day fraction from hours, minutes, and seconds. This offset is given by the larger of EPS and EPS*Julian, where Julian is the integer portion of the Julian date, and EPS is the EPS field from MACHAR. For typical Julian dates, this offset is approximately 6x10–10 (which corresponds to 5x10–5 seconds). This offset ensures that if the Julian date is converted back to hour, minute, and second, then the hour, minute, and second will have the same integer values as were originally input.

SECONDS

Set this keyword to specify that the current time is to be returned as the number of seconds elapsed since 1 January 1970 UTC. This option is equivalent to setting the SecondsFlag argument to a non-zero value.

UTC

Set this keyword to specify that the value returned by SYSTIME is to be returned in Universal Time Coordinated (UTC) rather than being adjusted for the current time zone. UTC time is defined as Greenwich Mean Time updated with leap seconds.

Examples

Print today’s date as a string:

PRINT, SYSTIME()

Print today’s date as a string in UTC (rather than local time zone):

PRINT, SYSTIME(/UTC)

Print today’s date as a Julian date/time value in UTC:

PRINT, SYSTIME(/JULIAN, /UTC), FORMAT='(f12.2)'

Compute and display the seconds elapsed since 1 January 1970 UTC, showing milliseconds (Windows) or microseconds (UNIX):

seconds = SYSTIME(1) ; or seconds = SYSTIME(/SECONDS)
PRINT, seconds, FORMAT='(D0.0)'

Verify that the seconds from the previous example are correct:

PRINT, SYSTIME(0, seconds)

Print the day of the week:

PRINT, STRMID(SYSTIME(0), 0, 3)

Compute the time required to perform a 16,384 point FFT:

T = SYSTIME(1)
A = FFT(FINDGEN(16384), -1)
PRINT, SYSTIME(1) - T, 'Seconds'

Version History

Original

Introduced

See Also

CALDAT , CALL_EXTERNAL , JULDAY , TIMEGEN